package net.kelissa.divizor.util.randomdata;

import java.util.HashMap;
import java.util.Map;

import net.kelissa.divizor.model.CellModel;
import net.kelissa.divizor.util.Const;
import net.kelissa.divizor.util.MathUtil;

/**
 * 2D random vector creator
 * @author tazzo
 *
 */
public class RandomCellCreator
{
  private int n;


  public RandomCellCreator()
  {
    this.n = 1;
  }

  public RandomCellCreator(int n)
  {
    this.n = n;
  }

  public Map<Integer, CellModel> createCells()
  {
    Map<Integer, CellModel> m = new HashMap<Integer, CellModel>();
    for (int i = 0; i < this.n; i++)
    {
      CellModel randomCell = createRandomCell();
      m.put(randomCell.getId(), randomCell);
    }
    return m;
  }

  public CellModel createRandomCell()
  {
    CellModel cm = new CellModel();
    double x = MathUtil.getDefaultRandom();
    double y = MathUtil.getDefaultRandom();
    double[] v = {x,y};
    cm.setPosition(v);
    String label1 = getLabel();
    String label2 = getLabel();
    v = new double[2];
    v[0] = MathUtil.getDefaultRandom();
    v[1] = MathUtil.getDefaultRandom();
    cm.setDivizor(v);
    cm.setClassLabelUp(label1);
    cm.setClassLabelDown(label2);
    cm.setCurvature(MathUtil.getDefaultRandom());
    return cm;
  }

  public  String getLabel()
  {
    double p = MathUtil.getDefaultRandom();
    String label;
    if(p>0)
    {
      label = Const.POSITIVE;
    }
    else
    {
      label = Const.NEGATIVE;
    }
    return label;
  }

}
